// home模块的小仓库
import { reqCategoryList, reqBannerList, reqFloorsList } from '@/api'
const actions = {
  // 请求三级导航数据
  async categoryList({ commit }) {
    try {
      let res = await reqCategoryList();
      if(res.code == 200){
        commit('CATEGORY_LIST', res.data);
      }
    } catch (error) {
      
    }
  },
  // 请求banner数据
  async getBannerList({ commit }) {
    let res = await reqBannerList();
    if(res.code == 200){
      commit('BANNER_LIST', res.data);
    }
  },
  // 请求floors数据
  async getFloorsList({ commit }) {
    let res = await reqFloorsList();
    if(res.code == 200){
      commit('FLOORS_LIST', res.data);
    }
  },
};
const mutations = {
  CATEGORY_LIST(state, categoryList) {
    state.categoryList = categoryList
  },
  BANNER_LIST(state, bannerList) {
    state.bannerList = bannerList;
  },
  FLOORS_LIST(state, floorsList) {
    state.floorsList = floorsList;
  }
};
const state = {
  // 三级联动导航
  categoryList: [],
  bannerList: [],
  floorsList: [],
};
const getters = {};
export default {
  namespaced: true,
  actions,
  mutations,
  state,
  getters,
}